﻿using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Abp.Web
{
    /// <summary>
    /// 书节点
    /// </summary>
    public class TreeNode
    {
        /// <summary>
        /// ID
        /// </summary>
        public object Id { get; set; }
        /// <summary>
        /// 文本信息
        /// </summary>
        public string Text { get; set; }
        /// <summary>
        /// 状态（展开和折叠）
        /// </summary>
        public string State { get; set; }
        /// <summary>
        /// 图标
        /// </summary>
        public string IconCls { get; set; }
        /// <summary>
        /// 选中状态
        /// </summary>
        public bool Checked { get; set; }
        /// <summary>
        /// 自定义属性
        /// </summary>
        public dynamic Attributes { get; set; }
        /// <summary>
        /// Target DOM object.
        /// </summary>
        public string Target { get; set; }
        /// <summary>
        /// 子节点
        /// </summary>
        public List<TreeNode> Children { get; set; }
        /// <summary>
        /// 上级编码
        /// </summary>
        public object ParentId { get; set; }
        /// <summary>
        /// 上下级关联当前ID，大多数时候是ID，特殊情况下和ID不同
        /// </summary>
        public object Ancestor { get; set; }

        public TreeNode()
        {
            State = TreeNodeState.Open;
        }
    }
    /// <summary>
    /// 树节点状态
    /// </summary>
    public static class TreeNodeState
    {
        /// <summary>
        /// 展开
        /// </summary>
        public const string Open = "open";
        /// <summary>
        /// 折叠
        /// </summary>
        public const string Closed = "closed";
    }

}
